package com.company.book_store.web.servlet;

import com.alibaba.fastjson.JSON;
import com.company.book_store.pojo.User;
import com.company.book_store.service.Iuserservice;
import com.company.book_store.service.UserserviceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

@WebServlet("/allUser")
public class allUser extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Iuserservice iuserservice = new UserserviceImpl();
        List<User> userList = iuserservice.selectall();
        String str = JSON.toJSONString(userList);
        PrintWriter out = resp.getWriter();
        out.write(str);

    }
}
